package cn.gzsxt.music.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.gzsxt.music.mapper.ModularMapper;
import cn.gzsxt.music.query.ModularQueryObject;
import cn.gzsxt.music.service.ModularService;

@Service
public class ModularServiceImpl implements ModularService {
	
	@Autowired
	private ModularMapper mapper;
	
	@Override
	public Map<String, Object> selectModularDataByCondition(ModularQueryObject qo) {
		//组装前台easyui datagrid对应需要数据格式的map集合
		Map<String, Object> dataGridMap = new HashMap<>();
		dataGridMap.put("total", mapper.selectModularTotalByCondition(qo));
		dataGridMap.put("rows", mapper.selectModularListByCondition(qo));
		
		return dataGridMap;
	}

	@Override
	public int saveOrUpdateModular(Map<String, Object> params) {
		if(StringUtils.isBlank((String)params.get("modular_id"))) {
			//新增操作
			return mapper.insert(params);
		}else {
			//修改操作
			return mapper.update(params);
		}
	}

@Override
public int deleteModularById(Long modular_id) {
	return mapper.deleteModularById(modular_id);
}

}
